package com.yonghui.springsecurityoauth2demo.utils;

import java.util.Base64;

/**
 * @author he_jiebing@jiuyv.com
 * @create 2024-05-17 17:24
 */
public class Base64Utils {
    /**
     * 将client_id和client_secret进行Base64编码
     *
     * @param clientId     客户端ID
     * @param clientSecret 客户端密钥
     * @return Base64编码后的字符串
     */
    public static String encodeClientCredentials(String clientId, String clientSecret) {
        String credentials = clientId + ":" + clientSecret;
        return Base64.getEncoder().encodeToString(credentials.getBytes());
    }

    public static void main(String[] args) {
        String clientId = "test";
        String clientSecret = "112233";
        String encodedCredentials = encodeClientCredentials(clientId, clientSecret);
        System.out.println("Encoded credentials: " + encodedCredentials);
    }
}
